import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { AdmCarDriveRecordVO, AdmCarDriveRecordForm, AdmCarDriveRecordQuery } from '@/api/general/administration/car/drive/types';

/**
 * 查询车辆行驶记录列表
 * @param query
 * @returns {*}
 */

export const listAdmCarDriveRecord = (query?: AdmCarDriveRecordQuery): AxiosPromise<AdmCarDriveRecordVO[]> => {
  return request({
    url: '/system/admCarDriveRecord/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询车辆行驶记录详细
 * @param id
 */
export const getAdmCarDriveRecord = (id: string | number): AxiosPromise<AdmCarDriveRecordVO> => {
  return request({
    url: '/system/admCarDriveRecord/' + id,
    method: 'get'
  });
};

/**
 * 新增车辆行驶记录
 * @param data
 */
export const addAdmCarDriveRecord = (data: AdmCarDriveRecordForm) => {
  return request({
    url: '/system/admCarDriveRecord',
    method: 'post',
    data: data
  });
};

/**
 * 修改车辆行驶记录
 * @param data
 */
export const updateAdmCarDriveRecord = (data: AdmCarDriveRecordForm) => {
  return request({
    url: '/system/admCarDriveRecord',
    method: 'put',
    data: data
  });
};

/**
 * 删除车辆行驶记录
 * @param id
 */
export const delAdmCarDriveRecord = (id: string | number | Array<string | number>) => {
  return request({
    url: '/system/admCarDriveRecord/' + id,
    method: 'delete'
  });
};

/**
 * 批量添加行驶记录
 * @param data 批量添加行驶记录的请求参数
 * @returns
 */
export function batchAddRecords(data: any) {
  return request({
    url: '/system/admCarDriveRecord/batchAdd',
    method: 'post',
    data
  })
}

// 批量修改
export const batchUpdateRecords = (payload: any) => {
  return request({
    url: '/system/admCarDriveRecord/batchUpdate',
    method: 'POST',
    data: payload
  })
}

/**
 * 获取可报销流程信息
 * @param id
 */
export const queryListByUser = (recordId: string | number , deptId: string | number, carId: string | number) => {
  return request({
    url: `/system/admCarDriveRecord/queryListByUser`,
    method: 'get',
    params: { recordId,deptId, carId }
  });
};

/**
 * 查询该车辆是否已经该报销过时间段
 * @param data
 */
export const isTimeHasReimburse = (data: AdmCarDriveRecordForm) => {
  return request({
    url: '/system/admCarDriveRecord/isTimeHasReimburse',
    method: 'post',
    data: data
  });
};